package com.wangshang.general.commodity.dao;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.wangshang.general.commodity.po.CommodityKinds;

/**
 * A data access object (DAO) providing persistence and search support for
 * CommodityKinds entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see com.wangshang.general.commodity.po.CommodityKinds
 * @author MyEclipse Persistence Tools
 */

public class CommodityKindsDAO extends HibernateDaoSupport {
	private static final Log log = LogFactory.getLog(CommodityKindsDAO.class);
	// property constants
	public static final String KIND_NAME = "kindName";
	public static final String ATTRIB_NAME0 = "attribName0";
	public static final String ATTRIB_NAME1 = "attribName1";
	public static final String ATTRIB_NAME2 = "attribName2";
	public static final String ATTRIB_NAME3 = "attribName3";
	public static final String ATTRIB_NAME4 = "attribName4";
	public static final String ATTRIB_NAME5 = "attribName5";
	public static final String ATTRIB_NAME6 = "attribName6";
	public static final String ATTRIB_NAME7 = "attribName7";
	public static final String ATTRIB_NAME8 = "attribName8";
	public static final String ATTRIB_NAME9 = "attribName9";
	public static final String ATTRIB_NAME10 = "attribName10";
	public static final String ATTRIB_NAME11 = "attribName11";
	public static final String ATTRIB_NAME12 = "attribName12";
	public static final String ATTRIB_NAME13 = "attribName13";
	public static final String ATTRIB_NAME14 = "attribName14";
	public static final String ATTRIB_NAME15 = "attribName15";

	protected void initDao() {
		// do nothing
	}

	public void save(CommodityKinds transientInstance) {
		log.debug("saving CommodityKinds instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(CommodityKinds persistentInstance) {
		log.debug("deleting CommodityKinds instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public CommodityKinds findById(java.lang.Integer id) {
		log.debug("getting CommodityKinds instance with id: " + id);
		try {
			CommodityKinds instance = (CommodityKinds) getHibernateTemplate()
					.get("com.wangshang.general.commodity.CommodityKinds", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(CommodityKinds instance) {
		log.debug("finding CommodityKinds instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding CommodityKinds instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from CommodityKinds as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByKindName(Object kindName) {
		return findByProperty(KIND_NAME, kindName);
	}

	public List findByAttribName0(Object attribName0) {
		return findByProperty(ATTRIB_NAME0, attribName0);
	}

	public List findByAttribName1(Object attribName1) {
		return findByProperty(ATTRIB_NAME1, attribName1);
	}

	public List findByAttribName2(Object attribName2) {
		return findByProperty(ATTRIB_NAME2, attribName2);
	}

	public List findByAttribName3(Object attribName3) {
		return findByProperty(ATTRIB_NAME3, attribName3);
	}

	public List findByAttribName4(Object attribName4) {
		return findByProperty(ATTRIB_NAME4, attribName4);
	}

	public List findByAttribName5(Object attribName5) {
		return findByProperty(ATTRIB_NAME5, attribName5);
	}

	public List findByAttribName6(Object attribName6) {
		return findByProperty(ATTRIB_NAME6, attribName6);
	}

	public List findByAttribName7(Object attribName7) {
		return findByProperty(ATTRIB_NAME7, attribName7);
	}

	public List findByAttribName8(Object attribName8) {
		return findByProperty(ATTRIB_NAME8, attribName8);
	}

	public List findByAttribName9(Object attribName9) {
		return findByProperty(ATTRIB_NAME9, attribName9);
	}

	public List findByAttribName10(Object attribName10) {
		return findByProperty(ATTRIB_NAME10, attribName10);
	}

	public List findByAttribName11(Object attribName11) {
		return findByProperty(ATTRIB_NAME11, attribName11);
	}

	public List findByAttribName12(Object attribName12) {
		return findByProperty(ATTRIB_NAME12, attribName12);
	}

	public List findByAttribName13(Object attribName13) {
		return findByProperty(ATTRIB_NAME13, attribName13);
	}

	public List findByAttribName14(Object attribName14) {
		return findByProperty(ATTRIB_NAME14, attribName14);
	}

	public List findByAttribName15(Object attribName15) {
		return findByProperty(ATTRIB_NAME15, attribName15);
	}

	public List findAll() {
		log.debug("finding all CommodityKinds instances");
		try {
			String queryString = "from CommodityKinds";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public CommodityKinds merge(CommodityKinds detachedInstance) {
		log.debug("merging CommodityKinds instance");
		try {
			CommodityKinds result = (CommodityKinds) getHibernateTemplate()
					.merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(CommodityKinds instance) {
		log.debug("attaching dirty CommodityKinds instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(CommodityKinds instance) {
		log.debug("attaching clean CommodityKinds instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static CommodityKindsDAO getFromApplicationContext(
			ApplicationContext ctx) {
		return (CommodityKindsDAO) ctx.getBean("CommodityKindsDAO");
	}
}